import { defineStore } from 'pinia'
import { ref } from 'vue'
export const userStore = defineStore(
  'userstore',
  () => {
    const token = ref('')
    const userinfo = ref({})
    const setToken = (t) => {
      token.value = t
    }
    const removeToken = () => {
      token.value = ''
    }
    const getToken = () => token.value
    const setUserInfo = (data) => {
      userinfo.value = data
    }
    const getUserInfo = () => userinfo.value
    return {
      token,
      userinfo,
      setToken,
      removeToken,
      getToken,
      setUserInfo,
      getUserInfo
    }
  },
  {
    persist: true
  }
)
